﻿
<template>
    <div class="main-content ft16  c666 padding20 yy">
        <h3 class="text-center" v-text="yyname"></h3>




        <div class="col-md-12 mb10">
            <h4 class="title ft16" style=" FONT-WEIGHT: 700;border-left: 3px solid #12b8f6;text-indent: 0.5em;display: inline-block;">物理表</h4>
        </div>
        <div class="col-md-2" v-for="(item, index) in tabledata" v-popover:popover>
            <i class="el-icon-error delyy" v-on:click.stop="deltab(item,index)"></i>
            <div class="thumbnail card"  @click="mgtab(item)">
                <img src="/ViewV5/images/icon/1.png" style="height: 60px; width: 60px; display: block; ">
                <div class="caption text-center" style="padding: 4px;">
                    <h5 v-text="item.TableDesc"></h5>
                </div>
            </div>
        </div>
        <div class="col-md-2">
            <div class="thumbnail card" @click="addtab()">
                <img src="/ViewV5/images/icon/Common.png" style="height: 60px; width: 60px; display: block; ">
                <div class="caption text-center" style="padding: 4px;">
                    <h5>添加</h5>
                </div>
            </div>
        </div>
        <div class="col-md-12 mb10">
            <h4 class="title ft16" style=" FONT-WEIGHT: 700;border-left: 3px solid #12b8f6;text-indent: 0.5em;display: inline-block;">数据集</h4>
        </div>
        <div class="col-md-2" v-for="(item, index) in datasetdata">
            <i class="el-icon-error delyy" v-on:click.stop="delset(item,index)"></i>

            <div class="thumbnail card" @click="mgset(item)">
                <img src="/ViewV5/images/icon/1.png" style="height: 60px; width: 60px; display: block; ">
                <div class="caption text-center" style="padding: 4px;">
                    <h5 v-text="item.Name"></h5>
                </div>
            </div>
        </div>
        <div class="col-md-2">
            <div class="thumbnail card" @click="addset()">
                <img src="/ViewV5/images/icon/Common.png" style="height: 60px; width: 60px; display: block; ">
                <div class="caption text-center" style="padding: 4px;">
                    <h5>添加</h5>
                </div>
            </div>
        </div>
        <div class="col-md-12 mb10">
            <h4 class="title ft16" style=" FONT-WEIGHT: 700;border-left: 3px solid #12b8f6;text-indent: 0.5em;display: inline-block;">自定义表单</h4>
        </div>
        <div class="col-md-2" v-for="(item, index) in formdata">
            <i class="el-icon-error delyy" v-on:click.stop="delform(item,index)"></i>
            <div class="thumbnail card" @click="mgform(item)">
                <img src="/ViewV5/images/icon/1.png" style="height: 60px; width: 60px; display: block; ">
                <div class="caption text-center" style="padding: 4px;">
                    <h5 v-text="item.ProcessName"></h5>
                    <!--<p class="ft12" style="margin-top: 2px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;" v-text="item.mc"> </p>-->
                </div>
            </div>
        </div>
        <div class="col-md-2">
            <div class="thumbnail card" @click="addform()">
                <img src="/ViewV5/images/icon/Common.png" style="height: 60px; width: 60px; display: block; ">
                <div class="caption text-center" style="padding: 4px;">
                    <h5>添加</h5>
                </div>
            </div>
        </div>
        <div class="col-md-12 mb10">
            <h4 class="title ft16" style=" FONT-WEIGHT: 700;border-left: 3px solid #12b8f6;text-indent: 0.5em;display: inline-block;">BI报表</h4>
        </div>
        <div class="col-md-2" v-for="(item, index) in ybdata">
            <i class="el-icon-error delyy" v-on:click.stop="delyb(item,index)"></i>
            <div class="thumbnail card" @click="mgyb(item)">
                <img src="/ViewV5/images/icon/1.png" style="height: 60px; width: 60px; display: block; ">
                <div class="caption text-center" style="padding: 4px;">
                    <h5 v-text="item.Name"></h5>
                    <!--<p class="ft12" style="margin-top: 2px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;" v-text="item.mc"> </p>-->
                </div>
            </div>
        </div>
        <div class="col-md-2">
            <div class="thumbnail card" @click="addyb()">
                <img src="/ViewV5/images/icon/Common.png" style="height: 60px; width: 60px; display: block; ">
                <div class="caption text-center" style="padding: 4px;">
                    <h5>添加</h5>
                </div>
            </div>
        </div>


        <div class="modal fade" id="TabModal" role="dialog">
            <div class="modal-dialog" role="document" style="width: 700px">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">添加表</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-horizontal">
                            <div class="form-group">
                                <label for="branchName" class="col-xs-3 control-label text-right">数据源</label>
                                <div class="col-xs-7">
                                    <select id="DTS" class="form-control">
                                        <option value="0">本地数据源</option>
                                        <option v-for="item in DSourData" :value="item.ID">{{item.Name}}</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="branchName" class="col-xs-3 control-label text-right">表名称(数据库表名)</label>
                                <div class="col-xs-7">
                                    <div class="input-group">
                                        <span class="input-group-addon" id="basic-addon1">qj_</span>
                                        <input type="text" class="form-control" id="BName" placeholder="表名称" />

                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="branchName" class="col-xs-3 control-label text-right">表别名</label>
                                <div class="col-xs-7">
                                    <div class="input-group">
                                        <input type="text" class="form-control" id="BBName" placeholder="表别名" />

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-info" @click="savetab()">确认</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="DetModal" role="dialog">
            <div class="modal-dialog" role="document" style="width: 700px">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">添加数据集</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-horizontal">

                            <div class="form-group">
                                <label for="branchName" class="col-xs-3 control-label text-right">数据集名称</label>
                                <div class="col-xs-7">
                                    <input type="text" class="form-control" id="DSName" placeholder="数据集名称" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="branchName" class="col-xs-3 control-label text-right">数据源</label>
                                <div class="col-xs-7">
                                    <select id="DTSSET" class="form-control">
                                        <option value="0">本地数据源</option>
                                        <option v-for="item in DSourData" :value="item.ID">{{item.Name}}</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-info" @click="saveset()">确认</button>
                    </div>
                </div>
            </div>
        </div>

        <div class="modal fade" id="YBModal" role="dialog">
            <div class="modal-dialog" role="document" style="width: 700px">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">添加仪表盘</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-horizontal">
                            <div class="form-group">
                                <label for="branchName" class="col-xs-3 control-label text-right">报表名称</label>
                                <div class="col-xs-7">
                                    <input type="text" class="form-control" id="YBName" placeholder="报表名称" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-info" @click="saveyb()">确认</button>
                    </div>
                </div>
            </div>
        </div>

    </div>
</template>
<style>

    .yy .col-md-2 {
        width: auto !important;
    }

    .card {
        border: 1px solid #eee;
        -webkit-transition: all .5s ease-in-out;
        -moz-transition: all .2s ease-in-out;
        transition: all .2s ease-in-out;
        width: 100PX;
        padding: 5PX;
    }

    .delyy {
        color: red;
        POSITION: ABSOLUTE;
        RIGHT: 10PX;
        TOP: -10PX;
        FONT-SIZE: 18PX;
        cursor: pointer;
        visibility: collapse;
    }

    .card:hover {
        box-shadow: 0px 2px 8px #3252f1;
        cursor: pointer;
        -webkit-transition: all .5s ease-in-out;
        -moz-transition: all .2s ease-in-out;
        transition: all .2s ease-in-out;
    }

    .col-md-2:hover .delyy {
        visibility: visible;
    }

    img {
        border-radius: 50%;
    }

    h5 {
        FONT-WEIGHT: 700;
        MARGIN-TOP: 2PX;
    }
</style>
<script>
    module.exports = {
        props: ['pdata'],
        data: function () {
            return {
                DSourData: [],
                tabledata: [],
                datasetdata: [],
                formdata: [],
                ybdata: [],
                modelid: "",
                yyname: "",
                DSData: {}
            }
        },
        methods: {
            addtab: function () {
                $('#TabModal').modal('show');
            },
            mgtab: function (rowdata) {
                window.open("/ViewV5/AppPage/DATABI/TABLEEDIT.html?id=" + rowdata.ID, "_blank");
            },
            deltab: function (item, index) {
                var pro = this;
                top.ComFunJS.winconfirm("确认要删除吗", function () {
                    $.getJSON('/api/Bll/ExeAction?Action=DATABI_DELTABLEDATA', { "P1": item.ID }, function (result) {
                        if (result.ErrorMsg == "") {
                            top.ComFunJS.winsuccess("删除成功");
                            pro.tabledata.splice(index, 1);
                        }
                    })
                }, function () { })
            },
            savetab: function () {
                if ($("#BName").val()) {
                    var pro = this;
                    $.getJSON('/api/Bll/ExeAction?Action=DATABI_ADDTABDATA', { P1: "qj_" + $("#BName").val(), DSID: $("#DTS").val(), SSMK: pro.modelid, P2: $("#BBName").val() }, function (resultData) {
                        if (resultData.ErrorMsg == "") {
                            top.ComFunJS.winsuccess("添加成功");
                            $('#TabModal').modal('hide');
                            pro.tabledata.push(resultData.Result)
                        }
                    })
                } else {
                    top.ComFunJS.winwarning("表名称不能为空!");

                }

            },

            addset: function () {
                $('#DetModal').modal('show');
            },
            mgset: function (rowdata) {
                window.open("/ViewV5/AppPage/DATABI/DSETEDIT.html?id=" + rowdata.ID, "_blank");
            },
            delset: function (item, index) {
                var pro = this;
                top.ComFunJS.winconfirm("确认要删除吗", function () {
                    $.getJSON('/api/Bll/ExeAction?Action=DATABI_DELBIDBSET', { "P1": item.ID }, function (result) {
                        if (result.ErrorMsg == "") {
                            top.ComFunJS.winsuccess("删除成功");
                            pro.datasetdata.splice(index, 1);
                        }
                    })
                }, function () { })
            },
            saveset: function () {
                var pro = this;
                pro.DSData = { Name: $("#DSName").val(), SName: $("#DSName").val(), Type: pro.modelid, ID: "0", SID: $("#DTSSET").val() };
                $.getJSON('/api/Bll/ExeAction?Action=DATABI_ADDBIDBSET', { P1: JSON.stringify(pro.DSData) }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        top.ComFunJS.winsuccess("操作成功");
                        pro.datasetdata.push(resultData.Result)
                        $('#DetModal').modal('hide');

                    }
                })
            },
            addform: function () {
                var pro = this;
                top.ComFunJS.winviewform("/ViewV5/AppPage/APP_ADD.html?FormCode=FORMBI_PROCESS&modelid=" + pro.modelid, "添加");
            },
            mgform: function (rowdata) {
                window.open("/ViewV5/AppPage/FORMBI/FormBuildV1.html?id=" + rowdata.ID, "_blank");
            },
            delform: function (item, index) {
                var pro = this;
                top.ComFunJS.winconfirm("确认要删除吗", function () {
                    $.getJSON('/api/Bll/ExeAction?Action=FORMBI_DELPROCESSBYID', { P1: item.ID }, function (result) {
                        if (result.ErrorMsg == "") {
                            top.ComFunJS.winsuccess("删除成功");
                            pro.formdata.splice(index, 1);
                        }
                    })
                }, function () { })
            },

            addyb: function () {
                $('#YBModal').modal('show');
            },
            mgyb: function (rowdata) {
                window.open("/ViewV5/AppPage/DATABI/YBPBuild.html?id=" + rowdata.ID, "_blank");

            },
            delyb: function (item, index) {
                var pro = this;
                top.ComFunJS.winconfirm("确认要删除吗", function () {
                    $.getJSON('/api/Bll/ExeAction?Action=DATABI_DELYBDATA', { "P1": item.ID }, function (result) {
                        if (result.ErrorMsg == "") {
                            top.ComFunJS.winsuccess("删除成功");
                            pro.ybdata.splice(index, 1);
                        }
                    })
                }, function () { })
            },
            saveyb: function () {
                var pro = this;
                $.getJSON('/api/Bll/ExeAction?Action=DATABI_SAVEDATA', { P1: $("#YBName").val(), dim: pro.modelid, }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        top.ComFunJS.winsuccess("添加成功");
                        pro.ybdata.push(resultData.Result)
                        $('#YBModal').modal('hide');
                    }
                })
            },


            InitWigetData: function () {
                var pro = this;
                $.getJSON('/api/Auth/ExeAction?Action=GETINITDATA', { P1: pro.modelid }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        pro.tabledata = resultData.Result;
                        pro.datasetdata = resultData.Result1;
                        pro.formdata = resultData.Result2;
                        pro.ybdata = resultData.Result3;
                        pro.DSourData = resultData.Result4;

                    }
                })
            },
        },
        mounted: function () {
            var pro = this;
            pro.$nextTick(function () {
                var rowdata = JSON.parse(pro.$root.pagedata.ExtData);
                pro.modelid = rowdata.ID;
                pro.yyname = rowdata.ModelName;

                pro.InitWigetData();

            })

        },
        watch: {

        }
    };
</script>